# -*- coding:utf-8 -*-
__author__: 'Rvelamen'
__data__ = '2022/3/16 22:59'

import uvicorn

from app.core.server import create_app
from app.db.redis import redis_client
from app.register.database import init_db

app = create_app()


@app.on_event("startup")
async def init_connect():
    # 连接redis
    redis_client.init_redis_connect()
    # 数据库初始化
    init_db()


@app.on_event('shutdown')
async def shutdown_connect():
    """
    关闭
    :return:
    """
    pass


if __name__ == "__main__":

    # 输出所有的路由
    for route in app.routes:
        if hasattr(route, "methods"):
            print({'path': route.path, 'name': route.name, 'methods': route.methods})

    uvicorn.run(app='main:app', host="127.0.0.1", port=5555)
    # uvicorn.run(app='main:app', host="127.0.0.1", port=5555, reload=True, debug=True)
